//
//  HomeBannerViewController.m
//  51易借
//
//  Created by apple on 2017/9/15.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "HomeBannerViewController.h"

@interface HomeBannerViewController ()
@property (nonatomic,strong)UIWebView * web;
@property (nonatomic,strong)UIView * topView;
@end

@implementation HomeBannerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self setupNavBar];
    [self setupUI];
    [self updateUI];
    // Do any additional setup after loading the view.
}



-(void)updateUI
{
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.title = self.banner.name;
    self.web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64 * SCREENH6, SCREEN_WIDTH, SCREENH_HEIGHT-64 * SCREENH6)];
    self.web.scalesPageToFit = YES;
    [self.view addSubview:self.web];
    [self.web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.banner.linkUrl]]];
}

- (void)setupNavBar{
    
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"箭头"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToLastView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}



- (void)setupUI{
    
    //    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIView * topView = [UIView new];
    
    topView.backgroundColor = ColorWithRGB(0xff7907);
    
    self.topView = topView;
    
    [self.view addSubview:self.topView];
    //
    
}


- (void)viewDidLayoutSubviews{
    
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.mas_equalTo(self.view);
        make.height.mas_equalTo(64 * SCREENH6);
    }];
}

-(void)backToLastView
{
    [self.navigationController popViewControllerAnimated:YES];
}





@end
